import router from "./index.js";
import myStore from "@/store";
const whiteList = ["/login"];
router.beforeEach((to, from, next) => {
  // console.log(myStore);
  if (myStore.getters.getToken) {
    if (to.path === "/login") {
      console.log("已经登录");
      next("/");
    } else {
      next();
    }
  } else {
    if (whiteList.includes(to.path)) {
      next();
    } else {
      next("/login");
    }
  }
  if (to.name !== "Login" && !isAuthenticated) next({ name: "Login" });
  else next();
});
